﻿///////////////////////////////////////////////////////////////////////////////
// File:        Realmd.h
// Author:      671643387@qq.com
// Date:        2016年1月18日 上午11:30:25
// Description:
///////////////////////////////////////////////////////////////////////////////

#ifndef REALMD_REALMD_H_
#define REALMD_REALMD_H_

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif

#include <cstdint>
#include <cstddef>

enum eAuthCmd
{
    CMD_AUTH_LOGON_CHALLENGE            = 0x00,
    CMD_AUTH_LOGON_PROOF                = 0x01,
    CMD_AUTH_RECONNECT_CHALLENGE        = 0x02,
    CMD_AUTH_RECONNECT_PROOF            = 0x03,
    CMD_REALM_LIST                      = 0x10,
    AUTH_TOTAL_COMMANDS
};

enum eAuthResult
{
    WOW_SUCCESS                         = 0x00,
    WOW_FAIL_UNKNOWN0                   = 0x01,
    WOW_FAIL_UNKNOWN1                   = 0x02,
    WOW_FAIL_BANNED                     = 0x03,
    WOW_FAIL_UNKNOWN_ACCOUNT            = 0x04,
    WOW_FAIL_INCORRECT_PASSWORD         = 0x05,

    WOW_FAIL_ALREAY_ONLINE              = 0x06,
    WOW_FAIL_NO_TIME                    = 0x07,
    WOW_FAIL_DB_BUSY                    = 0x08,
    WOW_FAIL_VERSION_INVALID            = 0x09,
    WOW_FAIL_VERSION_UPDATE             = 0x0A,
    WOW_FAIL_INVALID_SERVER             = 0x0B,
    WOW_FAIL_SUSPENDED                  = 0x0C,
    WOW_FAIL_FAIL_NOACCESS              = 0x0D,
    WOW_SUCCESS_SURVEY                  = 0x0E,
    WOW_FAIL_PARENTCONTROL              = 0x0F,
    WOW_FAIL_LOCKED_ENFORCED            = 0x10,
    WOW_FAIL_TRIAL_ENDED                = 0x11,
    WOW_FAIL_USE_BATTLENET              = 0x12
};

#if defined( __GNUC__ )
#pragma pack(1)
#else
#pragma pack(push,1)
#endif

typedef struct AUTH_LOGON_CHALLENGE_C
{
    ::std::uint8_t     cmd;
    ::std::uint8_t     error;
    ::std::uint16_t    size;
    ::std::uint8_t     gamename[4];
    ::std::uint8_t     version1;
    ::std::uint8_t     version2;
    ::std::uint8_t     version3;
    ::std::uint16_t    build;
    ::std::uint8_t     platform[4];
    ::std::uint8_t     os[4];
    ::std::uint8_t     country[4];
    ::std::uint32_t    timezone_bias;
    ::std::uint32_t    ip;
    ::std::uint8_t     I_len;
    ::std::uint8_t     I[1];
}sAuthLogonChallenge_C;

typedef struct AUTH_LOGON_PROOF_C
{
    ::std::uint8_t     cmd;
    ::std::uint8_t     A[32];
    ::std::uint8_t     M1[20];
    ::std::uint8_t     crc_hash[20];
    ::std::uint8_t     number_of_keys;
    ::std::uint8_t     securityFlags;
} sAuthLogonProof_C;

typedef struct AUTH_LOGON_PROOF_S_BUILD_6005
{
    ::std::uint8_t     cmd;
    ::std::uint8_t     error;
    ::std::uint8_t     M2[20];
    // ::std::uint32  unk1;
    ::std::uint32_t     unk2;
    // ::std::uint16  unk3;
} sAuthLogonProof_S_BUILD_6005;

typedef struct AUTH_RECONNECT_PROOF_C
{
    ::std::uint8_t     cmd;
    ::std::uint8_t     R1[16];
    ::std::uint8_t     R2[20];
    ::std::uint8_t     R3[20];
    ::std::uint8_t     number_of_keys;
} sAuthReconnectProof_C;

#if defined( __GNUC__ )
#pragma pack()
#else
#pragma pack(pop)
#endif

#endif /* REALMD_REALMD_H_ */
